import * as api from '@utils/wxRequest'
const nativePage = Page
Page = (options: any) => {
  merge(options)
  nativePage(options)
}

function merge(options: any) {
  if (options.onUnload) {
    let native = options.onUnload
    // options.onUnload = function () {
    //   cancelPageRequest.call(this)
    //   return native && native.call(this)
    // }
  } else {
    // options.onUnload = cancelPageRequest
  }
}

function cancelPageRequest() {
  const apiTest: any = api
  apiTest.request?.cancelPageRequest(apiTest.request.getCurrentPage())
}